package com.sky.controller.mirror;

import com.sky.entity.futu.Stock;
import com.sky.result.Result;
import com.sky.service.StockService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author : RemSynch
 * @Date: 2024/11/6 上午9:54
 * @Description:
 */
@RestController
@RequestMapping("/admin/stock")
@Api(tags = "后台管理正股")
public class StockController {
    @Autowired
    private StockService stockService;

    @ApiOperation("列表查询")
    @GetMapping
    public Result list() {
        return Result.success(stockService.list());
    }

    @ApiOperation("id查询")
    @GetMapping("/{id}")
    public Result get(@PathVariable Long id) {
        return Result.success(stockService.getById(id));
    }

    @ApiOperation("新增正股")
    @PostMapping
    public Result save(@RequestBody Stock stock) {
        return Result.status(stockService.save(stock));
    }

    @ApiOperation("更新正股")
    @PutMapping("/{id}")
    public Result update(@PathVariable Long id, @RequestBody Stock stock) {
        stock.setId(id);
        return Result.status(stockService.updateById(stock));
    }

    @ApiOperation("删除正股")
    @DeleteMapping("/{id}")
    public Result delete(@PathVariable Long id) {
        return Result.status(stockService.removeById(id));
    }
}
